﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace WpsReplace
{
    internal class WinApi
    {
        [DllImport("user32", EntryPoint = "GetWindowThreadProcessId")]
        public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int pid);

        //定义句柄的全局变量
        public int HANDLE;
        //定义回调函数的委托
        public delegate bool CALLBACK(int hwnd, int lparm);

        //用于获取前台窗口句柄,设置当前窗口句柄
        [DllImport("user32.dll")]
        public static extern int EnumWindows(CALLBACK x, int parent);

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int GetWindowText(int hWnd, StringBuilder lpText, int nCount);

        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern int GetWindowThreadProcessId(HandleRef handle, out int processId);

    }
}
